﻿@model IEnumerable<DotNetUniLodz.Models.Event>

@{
    ViewBag.Title = "Wydarzenia";
}

<div id="Content100">
    <h2>Wydarzenia</h2>
    @if (User.IsInRole("Admin"))
    {
        <header id="ContentHeaderLinks">
            @Html.ActionLink("+ Dodaj nowe wydarzenie", "Create")
        </header>
    }
    <div id="Columns">
        <section id="News" class="News100">
            @foreach (var item in Model)
            {
                <article class="Article100">
                    <header>
                        @Html.ActionLink(item.Event_name, "Details", "Events", new { id = item.Event_id }, null)
                    </header>
                    <div>
                        <span>Data wydarzenia: @item.Event_date.ToShortDateString() @item.Event_time</span>
                        <p>
                            @{
                item.Event_description = System.Text.RegularExpressions.Regex.Replace(item.Event_description, "<[^>]*>", string.Empty);
                            }
                            @if (item.Event_description.Length > 200)
                            {
                                @item.Event_description.Substring(0, 200)
                            }
                            else
                            {
                                @item.Event_description
                            }
                        </p>
                    </div>
                    <footer>
                        @{
                            if (item.Event_id != null)
                            {                    
                            <a href="@item.Event_link" class="ArticleRegister">Strona wydarzenia</a>
                            }            
                        }
                        @Html.ActionLink("Więcej informacji", "Details", "Events", new { id = item.Event_id }, new { @class = "ArticleMore" })

                        @if (User.IsInRole("Admin"))
                        {
                            <div class="AdminLinks">
                                @Html.ActionLink("Edytuj", "Edit", new { id = item.Event_id }) |
                        @Html.ActionLink("Usuń", "Delete", new { id = item.Event_id })
                            </div>
                        }
                    </footer>
                </article>
            }
        </section>
    </div>
</div>
